package com.chaoyer.cynet.common.domain;

import com.alibaba.fastjson.JSONObject;
import com.google.common.reflect.TypeToken;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Type;

@Getter
@Setter
public class HttpResult {

    private static final long serialVersionUID = -8670697419312384409L;

    private int code;
    private String content;
    private long costTime;

    public boolean success() {
        return getCode() == 200;
    }

    public <T> T getResult(Class<T> clazz) {
        return JSONObject.parseObject(getContent(), clazz);
    }

    public <T> T getResult(Type type) {
        return JSONObject.parseObject(getContent(), type);
    }

}